<?php

class PortalWebServiceException extends Exception{
	const SYSTEM_ERROR = -1;
	const PARAMETERS_ERROR = -2;
	static function errorHandler($number){
        if(in_array($number,array(E_NOTICE,E_USER_NOTICE,E_STRICT,E_RECOVERABLE_ERROR))){
            return false;
        }
        throw new Exception(print_r(func_get_args(),1));
	}
	static function exceptionHandler($e){
        error_log($e->getMessage()."\n".$e->getTraceAsString());
        exit(json_encode(self::SYSTEM_ERROR));
	}
}

set_error_handler('PortalWebServiceException::errorHandler');
set_exception_handler('PortalWebServiceException::exceptionHandler');
